// ... existing code ...
Page({
  data: {
    currentTab: 'daily',
    serviceType: '',
    date: '',
    startDate: '',
    timeSlots: ['08:00-10:00', '10:00-12:00', '14:00-16:00', '16:00-18:00'],
    timeSlotIndex: 0,
    // 家政保洁相关数据
    cleaningOptions: [
      { name: 'regular', value: '日常保洁', checked: true },
      { name: 'deep', value: '深度清洁' },
      { name: 'window', value: '窗户清洁' }
    ],
    cleaningArea: '',
    cleaningNote: '',
    // 快递入户相关数据
    expressCompany: '',
    expressNumber: '',
    expressNote: '',
    // 日用品订购相关数据
    shoppingList: '',
    shoppingNote: '',
    // 老人照护相关数据
    careDurations: ['2小时', '4小时', '8小时', '全天'],
    durationIndex: 0,
    elderlyAge: '',
    careLevels: [
      { name: 'basic', value: '基础照护', checked: true },
      { name: 'intermediate', value: '中级照护' },
      { name: 'advanced', value: '高级照护' }
    ],
    healthNeeds: '',
    elderlyNeeds: [
      { name: 'meal', value: '餐食服务', checked: false },
      { name: 'bath', value: '协助沐浴', checked: false },
      { name: 'medicine', value: '服药提醒', checked: false },
      { name: 'walk', value: '陪同散步', checked: false }
    ],
    contactPhone: '',
    elderlyNote: ''
  },

  onLoad: function(options) {
    // 设置默认日期为今天
    const today = new Date();
    const year = today.getFullYear();
    const month = String(today.getMonth() + 1).padStart(2, '0');
    const day = String(today.getDate()).padStart(2, '0');
    
    this.setData({
      startDate: `${year}-${month}-${day}`,
      serviceType: options.type || ''
    });
  },

  // ... existing methods ...

  // 照护级别选择
  bindCareLevelChange: function(e) {
    const value = e.detail.value;
    this.setData({
      careLevels: this.data.careLevels.map(item => ({
        ...item,
        checked: item.value === value
      }))
    });
  },

  // 老人特殊需求选择
  bindElderlyNeedChange: function(e) {
    const values = e.detail.value;
    this.setData({
      elderlyNeeds: this.data.elderlyNeeds.map(item => ({
        ...item,
        checked: values.includes(item.value)
      }))
    });
  },

  // 提交预约
  submitReservation: function() {
    const { serviceType } = this.data;
    let formData = {};
    let isValid = true;
    let errorMsg = '';
    
    // 根据服务类型收集不同的表单数据
    switch(serviceType) {
      // ... existing cases ...
      case 'elderly':
        formData = {
          type: 'elderly',
          date: this.data.date,
          duration: this.data.careDurations[this.data.durationIndex],
          age: this.data.elderlyAge,
          careLevel: this.data.careLevels.find(item => item.checked)?.value,
          healthNeeds: this.data.healthNeeds,
          specialNeeds: this.data.elderlyNeeds.filter(item => item.checked).map(item => item.value),
          contactPhone: this.data.contactPhone,
          note: this.data.elderlyNote
        };

        // 验证老人照护表单
        if (!formData.date) {
          isValid = false;
          errorMsg = '请选择服务日期';
        } else if (!formData.age || isNaN(formData.age) || formData.age < 60) {
          isValid = false;
          errorMsg = '请输入有效的老人年龄';
        } else if (!formData.contactPhone || formData.contactPhone.length !== 11) {
          isValid = false;
          errorMsg = '请输入有效的联系人电话';
        } else if (!formData.healthNeeds) {
          isValid = false;
          errorMsg = '请描述老人的健康状况';
        }
        break;
    }
    
    // 表单验证
    if (!isValid) {
      wx.showToast({
        title: errorMsg,
        icon: 'none'
      });
      return;
    }
    
    // 实际项目中，这里会调用API提交表单数据
    console.log('提交预约数据:', formData);
    
    wx.showToast({
      title: '预约成功',
      icon: 'success'
    });
  }
});
// ... existing code ...